package com.wswy.wzcx.model.weather

import android.os.Parcel
import android.os.Parcelable
import java.util.*

class ForecastWeather(
        /**
         * 预报时间
         */
        val date:Date?,

        /**
         * 白天天气温度
         */
        val dayTemp:String?,

        /**
         * 白天天气
         */
        val dayWeather:String?,

        /**
         * 白天风向
         */
        val dayWindDirection:String?,

        /**
         * 白天风力
         */
        val dayWindPower:String?,

        /**
         * 夜间天气温度
         */
        val nightTemp:String?,

        /**
         * 夜间天气
         */
        val nightWeather:String?,

        /**
         * 夜间风向
         */
        val nightWindDirection:String?,

        /**
         * 夜间风力
         */
        val nightWindPower:String?


) : Parcelable{


        constructor(parcel: Parcel) : this(
                parcel.readSerializable() as? Date,
                parcel.readString(),
                parcel.readString(),
                parcel.readString(),
                parcel.readString(),
                parcel.readString(),
                parcel.readString(),
                parcel.readString(),
                parcel.readString()) {
        }

        fun canWashCar():Boolean{
                return dayWeather == "晴" || dayWeather == "多云" || dayWeather == "阴"
        }

        override fun writeToParcel(parcel: Parcel, flags: Int) {
                parcel.writeSerializable(date)
                parcel.writeString(dayTemp)
                parcel.writeString(dayWeather)
                parcel.writeString(dayWindDirection)
                parcel.writeString(dayWindPower)
                parcel.writeString(nightTemp)
                parcel.writeString(nightWeather)
                parcel.writeString(nightWindDirection)
                parcel.writeString(nightWindPower)
        }

        override fun describeContents(): Int {
                return 0
        }

        companion object CREATOR : Parcelable.Creator<ForecastWeather> {
                override fun createFromParcel(parcel: Parcel): ForecastWeather {
                        return ForecastWeather(parcel)
                }

                override fun newArray(size: Int): Array<ForecastWeather?> {
                        return arrayOfNulls(size)
                }
        }


}